﻿using B.S.BasicData.Domain;
using B.S.BasicData.ErrorCode;
using B.S.BasicData.Write.Application.Common.Menu;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.BasicData.Write.Controllers
{
    /// <summary>
    /// Api 控制器 -菜单管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class MenuController : ControllerBase
    {
        private readonly IMediator mediator;

        public MenuController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 菜单信息增加
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<MenuModel>> MenuAdd(MenuAddCommand command)
        { 
            return mediator.Send(command);
            
        }

        /// <summary>
        /// 菜单列表信息修改
        /// </summary>
        /// <param name="common"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> UpdateMenu(UpdateMenuCommon common)
        {
            return mediator.Send(common);
        }

        /// <summary>
        /// 菜单列表信息删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> DelMenuHandle(DelMenuCommand request)
        {
            return await mediator.Send(request);
        }



    }
}
